﻿using ZYCommon;
using System;
using System.Drawing;
using System.Xml;

namespace TextEditor
{
   

    public abstract class ImageEditAction
    {
        protected Rectangle myBounds = Rectangle.Empty;

        protected ImageEditAction()
        {
        }

        public bool BoundsFromXML(XmlElement myElement)
        {
            this.myBounds = new Rectangle(Convert.ToInt32(myElement.GetAttribute("left")), Convert.ToInt32(myElement.GetAttribute("top")), Convert.ToInt32(myElement.GetAttribute("width")), Convert.ToInt32(myElement.GetAttribute("height")));
            return true;
        }

        public bool BoundsToXML(XmlElement myElement)
        {
            myElement.SetAttribute("left", this.myBounds.Left.ToString());
            myElement.SetAttribute("top", this.myBounds.Top.ToString());
            myElement.SetAttribute("width", this.myBounds.Width.ToString());
            myElement.SetAttribute("height", this.myBounds.Height.ToString());
            return true;
        }

        public virtual bool DesignChangeBounds(Rectangle NewBounds)
        {
            this.Bounds = NewBounds;
            return true;
        }

        public virtual bool Execute(Graphics g, Rectangle ClipRect)
        {
            return false;
        }

        public virtual bool FromXML(XmlElement myElement)
        {
            return false;
        }

        public Rectangle[] GetDragRects()
        {
            return DocumentView.GetDragRects(this.Bounds, 4, true);
        }

        public virtual bool IsVisible(Rectangle ClipRect)
        {
            return true;
        }

        public virtual bool ToXML(XmlElement myElement)
        {
            return false;
        }

        public virtual string ActionName
        {
            get
            {
                return null;
            }
        }

        public virtual Rectangle Bounds
        {
            get
            {
                return this.myBounds;
            }
            set
            {
                this.myBounds = value;
            }
        }

        public virtual bool Selectable
        {
            get
            {
                return true;
            }
        }
    }
}

